package com.ruoyi.web.controller.wxqy;

import com.ruoyi.common.annotation.ControllerAuthority;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.NumberUtils;
import com.ruoyi.qywx.model.vo.ContactVo;
import com.ruoyi.qywx.model.vo.DeptVo;
import com.ruoyi.qywx.service.inters.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : hcl
 * @Date : 2023/8/14 10:39
 */
@RestController
@ControllerAuthority
@RequestMapping("/wxqy/contact")
public class ContactController extends BaseController {
    @Autowired
    private ContactService contactService;

    @GetMapping("/list")
    public AjaxResult contactList(@RequestParam(required = false) Long deptId,
                                  @RequestParam(required = false) String name) {
        List<ContactVo> vos = contactService.contactList(deptId, name, getTeamId());
        return success(vos);
    }

    @GetMapping("/dept/list")
    public AjaxResult deptList(@RequestParam(required = false, defaultValue = "0") Long deptId) {
        List<DeptVo> vos = contactService.deptList(deptId, getTeamId());
        return success(vos);
    }

}
